//
//  ViewController.swift
//  myswift
//
//  Created by Harry on 15/6/9.
//  Copyright (c) 2015年 yangtuoxs. All rights reserved.
//

import UIKit


class MyViewController: UIViewController ,UITableViewDataSource {

    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        print("Hello world!")
        let label="labelwidth"
        let str=443
        let ss=label+String(str)
        print(ss)
        
        var optionalString: String="hello"
        var optionalName=optionalString;

        optionalName="Mr.Su"
        print(optionalString + optionalName)

        var arr=Array(count: 10, repeatedValue: 1.0)
    
//        optionalName=""
        if optionalName.characters.count>0 {
            print("it is true")
        }else{
            print("it is false")
        }
        
        var btn = UIButton ()
        btn.setTitle("按钮", forState:UIControlState.Normal)
        btn.addTarget(self, action:"buttonClick:", forControlEvents: UIControlEvents.TouchUpInside)
        
        btn.frame=CGRectMake(110, 100, 100, 50)
        btn.setTitleColor(UIColor.redColor(), forState: UIControlState.Normal)
        btn.layer.borderWidth=2.0
        btn.layer.cornerRadius=5.0
//        btn.showsTouchWhenHighlighted=true
        btn.layer.borderColor=UIColor.redColor().CGColor
        view.addSubview(btn)
        
        
        var logvc=LoginViewController ()
        logvc.testSwift()
        
        var sw = MyFirstClass ()
            sw.yForx = { (x: Double) -> Double?  in
            
            
            return 3.0
        }
        
        
        var res: Double = 88.0 {
            willSet{
                print("\(newValue)")
            }
            didSet{
                print("\(oldValue)")
            }
        }
        
        res = 99.0
        
    }
    
    func greet(name : String , day:String)->String{
        return name
    }
    
    func getGasPrice()->(Double,Float,Int){
        return(30.0,20.0,12)
    }
    
    func sayHelloOC() {
        print("hhhhhhhhhhhhhhhhhhhhhhhhhh")
    }
    
    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
    {
        return 1
    }
    
    func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        return 1
    }
    
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell=UITableViewCell (style: .Default, reuseIdentifier: "cellId")
        
        
        return cell
    }
    
    func buttonClick (sender:UIButton!)
    {
        print("hello world", terminator: "")
        
    }

    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

